//package com.momoback.util;
//
//import org.apache.http.HttpEntity;
//import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPut;
//import org.apache.http.entity.ContentType;
//import org.apache.http.entity.mime.HttpMultipartMode;
//import org.apache.http.entity.mime.MultipartEntityBuilder;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.util.EntityUtils;
//
//import java.io.File;
//import java.io.IOException;
//import java.nio.file.Files;
//import java.nio.file.Paths;
//import java.util.Base64;
//
//public class FileUploader {
//
//    public static void uploadFilePut(String targetUrl, String filePath) {
//        // 创建HttpClient实例
//        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
//            // 创建HttpPost实例
//            HttpPut httpPut = new HttpPut(targetUrl);
//
//            // 准备文件
//            String formattedPath = filePath.replace("\\", "\\\\");
//            File file = new File(formattedPath);
//
//            // 使用MultipartEntityBuilder构建multipart/form-data请求体
//            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
//            builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
//            builder.addBinaryBody("file", file, ContentType.DEFAULT_BINARY, file.getName());
//
//            // 构建请求体
//            HttpEntity multipart = builder.build();
//            httpPut.setEntity(multipart);
//
//            // 发送请求
//            try (CloseableHttpResponse response = httpClient.execute(httpPut)) {
//                // 检查响应状态
//                if (response.getStatusLine().getStatusCode() == 200) {
//                    System.out.println("File uploaded successfully");
//                } else {
//                    System.out.println("File upload failed");
//                }
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//    public static void uploadFileGET(String targetUrl, String filePath) {
//        // 创建HttpClient实例
//        try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
//            // 创建HttpPost实例
//            HttpGet httpGet = new HttpGet(targetUrl);
//
//            // 准备文件
//            String formattedPath = filePath.replace("\\", "\\\\");
//            File file = new File(formattedPath);
//
//            // 使用MultipartEntityBuilder构建multipart/form-data请求体
//            MultipartEntityBuilder builder = MultipartEntityBuilder.create();
//            builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
//            builder.addBinaryBody("file", file, ContentType.DEFAULT_BINARY, file.getName());
//
//            // 构建请求体
//            HttpEntity multipart = builder.build();
//
//
//            // 发送请求
//            try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
//                // 检查响应状态
//                if (response.getStatusLine().getStatusCode() == 200) {
//                    System.out.println("File uploaded successfully");
//                } else {
//                    System.out.println("File upload failed");
//                }
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//
//}